package com.xiaoq.shop.endpoint;

import com.xiaoq.BaseEndpoint2B;
import com.xiaoq.coms.GenericDataResponse;
import com.xiaoq.shop.entity.TicketSellPlatformEntity;
import com.xiaoq.shop.service.ITicketSellPlatformService;
import com.xiaoq.shop.vo.TicketSellPlatformVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chenjh on 2018/7/13.
 */
@RestController
@RequestMapping(value = "/api/v1/sellPlatform")
public class TicketSellPlatformEndpoint2B extends BaseEndpoint2B {

    private static final class TicketSellPlatformResponse extends GenericDataResponse<TicketSellPlatformVo> {}

    @Autowired
    private ITicketSellPlatformService ticketSellPlatformService;

    @ApiOperation(value="第三方发码平台", notes="第三方发码平台")
    @ApiResponses({
            @ApiResponse(code = 200, response = TicketSellPlatformResponse.class, message = "第三方发码平台")
    })
    @GetMapping(value="", produces={MediaType.APPLICATION_JSON_UTF8_VALUE})
    public ResponseEntity<?> sellPlatform() {
        String shopId = getShopId();
        TicketSellPlatformEntity sellPlatformEntity = ticketSellPlatformService.getBySitesId(shopId);
        TicketSellPlatformVo ticketSellPlatformVo = new TicketSellPlatformVo();
        if(sellPlatformEntity != null){
            BeanUtils.copyProperties(sellPlatformEntity, ticketSellPlatformVo);
        }
        return TicketSellPlatformResponse.okWithData(ticketSellPlatformVo);
    }

}
